package com.example.snackfood.controller;

import com.example.snackfood.entity.Carts;
import com.example.snackfood.entity.Payments;
import com.example.snackfood.services.IsnackFoodPaymentsService;
import com.example.snackfood.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: snackFood
 * @description:
 * @author: lydms
 * @create: 2023-11-24 22:48
 **/

@RestController
@RequestMapping("/Payments")
public class SnackFoodPaymentsController {

    @Autowired
    private IsnackFoodPaymentsService snackFoodPaymentsService;


    //增：Carts
    @PostMapping("/save")
    public R savePayments(@RequestBody Payments payments) {
        snackFoodPaymentsService.savePayments(payments);
        return R.success("增加成功");
    }
    //删：
    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable Long id){
        snackFoodPaymentsService.deletePayments(id);
        return R.success("成功删除");
    }

    //改：
    @PutMapping("/update")
    public R update(@RequestBody Payments payments){
        snackFoodPaymentsService.updatePayments(payments);
        return R.success(payments);
    }

    //查（条件查询）：
    @GetMapping("/get")
    public Payments getCarts(@RequestBody Payments payments){return snackFoodPaymentsService.getPayments(payments);}
}
